package test;

import java.awt.event.ActionEvent;

import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

import net.miginfocom.swing.MigLayout;

@SuppressWarnings("serial")
class LoginView extends JPanel {

	public static void main(String... args) {

	}

	private final JLabel labelUsername = new JLabel("Username");
	private final JTextField textUsername = new JTextField();

	private final JLabel labelPassword = new JLabel("Password");
	private final JTextField textPassword = new JTextField();

	private final JLabel labelRemember = new JLabel("Remember");
	private final JCheckBox checkRemember = new JCheckBox("");

	private final JLabel labelAuto = new JLabel("Auto Login");
	private final JCheckBox checkAuto = new JCheckBox("");

	private final Action actionLogin = new ActionLogin();
	private final Action actionCancel = new ActionCancel();

	private final JButton buttonLogin = new JButton(actionLogin);
	private final JButton buttonCancel = new JButton(actionCancel);

	//

	public LoginView() {
		initGUI();
	}

	private void initGUI() {

		MigLayout mig = new MigLayout("", "[][][][]", "[][][][][][]");
		setLayout(mig);

		add(labelUsername, "cell 0 0");

		add(textUsername, "cell 1 0 2 1,growx");

		add(labelPassword, "cell 0 1");

		add(textPassword, "cell 1 1 2 1,growx");

		add(labelRemember, "cell 0 2");

		add(checkRemember, "cell 1 2");

		add(labelAuto, "cell 0 3");

		add(checkAuto, "cell 1 3");

		add(buttonLogin, "cell 1 4");

		add(buttonCancel, "cell 2 4");

	}

	public JTextField getTextUsername() {
		return textUsername;
	}

	public JTextField getTextPassword() {
		return textPassword;
	}

	public JCheckBox getCheckRemember() {
		return checkRemember;
	}

	public JCheckBox getCheckAuto() {
		return checkAuto;
	}

	private class ActionLogin extends AbstractAction {
		public ActionLogin() {
			putValue(NAME, "Login");
		}

		@Override
		public void actionPerformed(ActionEvent e) {
		}
	}

	private class ActionCancel extends AbstractAction {
		public ActionCancel() {
			putValue(NAME, "Cancel");
		}

		@Override
		public void actionPerformed(ActionEvent e) {
		}
	}

}
